Skip to content

Conversation

@tlyu
Copy link

@tlyu tlyu commented Jun 6, 2022

Mixing unsigned long and int on LP64 platforms caused the chunksize adjustment to be wrong for flash memory reads from "negative" addresses. This caused runaway reads and heap corruption, because chunksize was being adjusted to be greater than numBytes. Simplify the computation by computing the offset within the page using a mask, and use the difference between pageSize and offset to limit chunksize.

This is less necessary after the qXfer:memory-map:read support was added, but it's definitely needed in 2.13, and maybe some older GDB versions don't support qXfer:memory-map:read.

Fixes #107.

@tlyu tlyu marked this pull request as draft December 28, 2023 03:26
@tlyu
Copy link
Author

tlyu commented Dec 28, 2023

Converted to draft, because jtag3rw.cc probably also needs a similar change.

Mixing unsigned long and int on LP64 platforms caused the chunksize
adjustment to be wrong for flash memory reads from "negative"
addresses. This caused runaway reads and heap corruption, because
chunksize was being adjusted to be greater than numBytes. Simplify
the computation by computing the offset within the page using a mask,
and use the difference between pageSize and offset to limit chunksize.

This is less necessary after the qXfer:memory-map:read support
was added, but it's definitely needed in 2.13, and maybe some
older GDB versions don't support qXfer:memory-map:read.
@tlyu tlyu marked this pull request as ready for review December 28, 2023 17:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

DebugWire flash read causes heap corruption on LP64 hosts

1 participant